home *** CD-ROM | disk | FTP | other *** search
/ Java Interactive Reference Guide / Java Interactive Reference Guide.iso / autorun / source.dir / 00058_15.txt < prev    next >
Encoding:
Text File  |  1980-01-11  |  342 b   |  14 lines

  1. import java.awt.Graphics;
  2.  
  3. public class GraphApplet extends java.applet.Applet {
  4.     double f(double x) {
  5.     return (Math.cos(x/5) + Math.sin(x/7) + 2) * size().height / 4;
  6.     }
  7.  
  8.     public void paint(Graphics g) {
  9.         for (int x = 0 ; x < size().width ; x++) {
  10.         g.drawLine(x, (int)f(x), x + 1, (int)f(x + 1));
  11.         }
  12.     }
  13. }
  14.